﻿<?php 
	include("qldb_script.php"); 
	include("qldb_action.php"); 
	if(!empty($_POST['hanhdong'])){
		if($_POST['hanhdong'] == "them"){		
			themDanhBa(); 
		}		
		if($_POST['hanhdong'] == "sua"){	
			suaDanhBa($_POST['idSua']);
		}	
	}	
?>
<div class="wrap">
<h2>Thông Tin Danh Bạ</h2>
<!--ul class="subsubsub">
    <li class="all"><a href="#" class="current">Tất cả <span class="count">(1)</span></a></li>
</ul-->
<!--thêm-->        
		<form class="add-contact" action="?page=Quan_ly_danh_ba" method="post">
			<table class="wp-list-table" cellspacing="0" width="100%">
				<thead>
				<tr>
					<input type="hidden" name="hanhdong" id="hanhdong" value="them"/>
					<input type="hidden" name="idSua" id="idSua" value=""/>
					<th scope="col" class="manage-column column-title sortable desc">
						<div class="add-record">
							<input type="text" id="input-hoten" name="input-hoten" placeholder="Họ và tên">
						</div>
					</th>
					<th scope="col" class="manage-column column-danhba">
						<div class="add-record">
							<input type="text" id="input-sdt" name="input-sdt" placeholder="Số Điện Thoại">
						</div>
					</th>
					<th scope="col" class="manage-column column-danhba">
						<div class="add-record">
							<input type="email" id="input-email" name="input-email" placeholder="Email">
						</div>
					</th>
					<th scope="col" class="manage-column column-danhba">
						<div class="add-record">
							<input type="date" id="input-date" name="input-ngaysinh" placeholder="Ngày Sinh">
						</div>

					</th>
					
					<th scope="col" class="manage-column column-danhba">
						<div class="add-record">
							<input type="text" id="input-diachi" name="input-diachi" placeholder="Địa Chỉ">
						</div>
					</th>
                    <th scope="col" class="manage-column column-danhba">
						<input type="submit" name="submit-add" class="button" id="submit-add" value="Thêm danh bạ">
						<input type="button" name="huy-sua" class="button" id="huy-sua" onClick="huySua()" value="Hủy">
					</th>
				</tr>
				</thead>
			 </table>          
         <!--end thêm  -->	
		</form>
	<form id="posts-filter" action="" method="post">
        <!--tìm kiếm-->
        <input type="hidden" name="hanhdong" value="tim"/>
        <p class="search-box">
            <input type="search" id="search-input" name="searchText" value="" placeholder="Tìm kiếm">
            <input type="submit" name="" id="search-submit" class="button" value="Tìm">
        </p>
    </form>
    <!--end tìm kiếm-->
    <!--input type="hidden" name="post_status" class="post_status_page" value="all">
    <input type="hidden" name="post_type" class="post_type_page" value="post">
    <input type="hidden" id="_wpnonce" name="_wpnonce" value="3cc495f09a"><input type="hidden" name="_wp_http_referer" value=""-->
    <table class="wp-list-table widefat fixed posts" cellspacing="0">
        <thead>
        <!-- Tiêu đề -->
        <tr>
            <th scope="col" id="cb" class="manage-column column-cb check-column" style="">
                <label class="screen-reader-text" for="cb-select-all-1">Chọn tất cả</label>
                <input id="cb-select-all-1" type="checkbox">
            </th>
            <th scope="col" id="title" class="manage-column column-title sortable desc" style="">
                <a href="#">
                    <span>Họ và tên</span>
                    <span class="sorting-indicator"></span>
                </a>
            </th>
				<th scope="col" id="sdt" class="manage-column column-danhba" style="">
					Số điện thoại
				</th>
				<th scope="col" id="email" class="manage-column column-danhba" style="">
					Email
				</th>
				<th scope="col" id="ngaysinh" class="manage-column column-danhba" style="">
				   Ngày sinh
				</th>
				<th scope="col" id="diachi" class="manage-column column-danhba" style="">
					Địa chỉ
				</th>
            <th scope="col" id="date" class="manage-column column-danhba sortable asc" style="">
                <a href="#">
                    <span>Ngày thêm</span>
                    <span class="sorting-indicator"></span>
                </a>
            </th>
        </tr>

        <!-- end Tiêu đề -->
        </thead>
		
        <?php
			if(!empty($_POST['hanhdong'])){
				if($_POST['hanhdong'] == "tim"){
					$s = $_POST['searchText'];
					$exQ =  'WHERE Ten LIKE "%'. $s .
							'%" OR SoDt LIKE "%'. $s .
							'%" OR Email LIKE "%'. $s .
							'%" OR NgaySinh LIKE "%'. $s .
							'%" OR DiaChi LIKE "%'. $s . '%"';
					xemDanhBa($exQ);
				}
				else
				{ xemDanhBa("");}
			}
			else
			{ xemDanhBa("");}				
			if($_GET['suaid']){
				echo "<script>sua('sua-" . $_GET['suaid'] . "');</script>";
			}
		 ?>

    </table>
</div>
<!-- end xem danh bạ-->